<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition  xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="/pages/template.xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>

<body>
<ui:define name="content">
<f:view>
	<h:form>
			<fieldset><legend>Manter Estabelecimento - Alterar</legend> 
				<a4j:region id="regiaoAjax">
					<a4j:status id="sts">
	                    <f:facet name="start">
	            		     <h:graphicImage value="/images/ajax-loader.gif" />
	               		</f:facet>
	                </a4j:status>
	            </a4j:region>
				<h:panelGrid columns="3" id="inputsAlterar" >
                    <h:outputLabel value="Estabelecimento" for="nmEstabelecimento" />
                    <h:inputText label="Estabelecimento" size="40" id="nmEstabelecimento" value="#{estabelecimentoMB.estabelecimentoTO.nmEstabelecimento}"  required="true">
                    <f:validateLength maximum="100"/>
                    </h:inputText>
                    
                    <h:message for="nmEstabelecimento" style="color:red"/>
					
                    <h:outputLabel value="UF" for="idUf" />
                    <h:selectOneMenu  label="UF" id="idUf" value="#{estabelecimentoMB.estabelecimentoTO.idUf}" rendered="true" required="true" >
                    	<f:selectItem itemValue="" itemLabel="Selecione..." />
                        <f:selectItems value="#{estabelecimentoMB.cbxUfs}"/>
                        <a4j:support event="onchange" ajaxSingle="true" action="#{estabelecimentoMB.carregarCidadesPorIdUf}" reRender="idUf, idCidade"/>
                    </h:selectOneMenu>
                     <h:message for="idUf" style="color:red"/>
                     
                    <h:outputLabel value="Cidade" for="idCidade" />
                    <h:selectOneMenu label="Cidade" id="idCidade" value="#{estabelecimentoMB.estabelecimentoTO.idCidade}"  rendered="true" required="true" >
                    	<f:selectItem itemValue="" itemLabel="Selecione..." />
                        <f:selectItems value="#{estabelecimentoMB.cbxTodasCidades}"/>
                        <a4j:support event="onchange" ajaxSingle="true" action="#{estabelecimentoMB.carregarBairrosPorIdCidade}" reRender="idUf, idCidade, idBairro"/>
                    </h:selectOneMenu>
                    <h:message for="idCidade" style="color:red"/>
                    
                    <h:outputLabel value="Bairro" for="idBairro" />
                    <h:selectOneMenu label="Bairro" id="idBairro" value="#{estabelecimentoMB.estabelecimentoTO.idBairro}"  rendered="true" required="true" >
                    	<f:selectItem itemValue="" itemLabel="Selecione..." />
                        <f:selectItems value="#{estabelecimentoMB.cbxTodosBairros}"/>
                    </h:selectOneMenu>
					<h:message for="idBairro" style="color:red"/>
                                                                               
                    <h:outputLabel value="Logradouro" for="dsEndereco" />
                    <h:inputText label="Endereço" size="40" id="dsEndereco" value="#{estabelecimentoMB.estabelecimentoTO.nmLogradouro}" required="true" >
                    <f:validateLength maximum="50"/>
                    </h:inputText>
                    <h:message for="dsEndereco" style="color:red"/>
                    
                    <h:outputLabel value="Número" for="nuComplemento" />
                    <h:inputText label="Complemento" size="40" id="nuComplemento" value="#{estabelecimentoMB.estabelecimentoTO.nuEstabelecimento}"  required="true" />
                    <h:message for="nuComplemento" style="color:red"/>
                     
                    <h:outputLabel value="Telefone" for="nuTelefone" />
                    <h:inputText label="Telefone" size="40" id="nuTelefone" value="#{estabelecimentoMB.estabelecimentoTO.nuTelefone}"  required="true">
                    <rich:jQuery selector="#nuTelefone" query="mask('(99)9999-9999')" timing="onload"/>
                    <f:converter converterId="phoneNumber" />
                    </h:inputText>
                    <h:message for="nuTelefone" style="color:red"/>
                    
                    <h:outputLabel value="Descrição" for="dsDescricao" />
                    <h:inputText label="Descricao" size="40" id="dsDescricao" value="#{estabelecimentoMB.estabelecimentoTO.dsEstabelecimento}"  />
					<h:message for="dsDescricao" style="color:red"/>

                    <h:outputLabel value="Ativo" for="inAtivo" />
                    <h:selectOneMenu label="Ativo" id="inAtivo" value="#{estabelecimentoMB.estabelecimentoTO.inAtivo}">
                    	<f:selectItem itemValue="" itemLabel="Selecione..." />
                        <f:selectItems value="#{estabelecimentoMB.carregarSimNao}"/>
                    </h:selectOneMenu>
					<h:message for="inAtivo" style="color:red"/>
		    	</h:panelGrid>
		    	<h:panelGroup  styleClass="alignRight">
		    		<a4j:htmlCommandLink  value="Alterar" action="#{estabelecimentoMB.alterar}" status="sts" reRender="inputsAlterar" styleClass="grey-button pcb"/>
					<a4j:htmlCommandLink  value="Cancelar" immediate="true" action="#{estabelecimentoMB.iniciarEstabelecimento}" styleClass="linkbotao"/>
		    	</h:panelGroup>
		</fieldset>
				
	</h:form>
</f:view>
</ui:define>
</body>
</ui:composition>